
public class Test {
    @Override
    public String toString() {
        return "Test{}";
    }

   /* public static void main(String[] args) {
       Dog dog = new Dog("圆圆",10);
       dog.eat();
       dog.Bark();
       System.out.println("===========");
       dog.Bark();
       Animal animal = new Dog("花花",19);
       *//*
       多态(向上转型,重写,动态绑定)
       向上转型(直接赋值,方法传参,返回值)
        *//*
       animal.eat();
        Animal animal1 = new Cat("十三",2);
       System.out.println(dog);
       animal1.eat();

    }
*/
   public static void main(String[] args) {
       Animal dog = new Dog("yuaunyaun",12);
       Animal cat = new Cat("shisan",12);
        eatFun(dog);
        eatFun(cat);

        Dog dog1 = (Dog)dog;
        dog1.Bark();
        //向下转型

       //类型转换异常
       if(dog instanceof  Cat){
           Cat cat1 = (Cat) cat;
           cat1.mew();
       }else{
           System.out.println("向下转型失败");
       }
   }

    public static void eatFun(Animal animal) {
        animal.eat();
    }
}
